#include <stm8s_clk.h>

void CLK_ITConfig(CLK_IT_TypeDef CLK_IT, FunctionalState NewState)
{
  /* check the parameters */
  assert_param(IS_FUNCTIONALSTATE_OK(NewState));
  assert_param(IS_CLK_IT_OK(CLK_IT));
  
  if (NewState != DISABLE)
  {
    switch (CLK_IT)
    {
    case CLK_IT_SWIF: /* Enable the clock switch interrupt */
      CLK->SWCR |= CLK_SWCR_SWIEN;
      break;
    case CLK_IT_CSSD: /* Enable the clock security system detection interrupt */
      CLK->CSSR |= CLK_CSSR_CSSDIE;
      break;
    default:
      break;
    }
  }
  else  /*(NewState == DISABLE)*/
  {
    switch (CLK_IT)
    {
    case CLK_IT_SWIF: /* Disable the clock switch interrupt */
      CLK->SWCR  &= (uint8_t)(~CLK_SWCR_SWIEN);
      break;
    case CLK_IT_CSSD: /* Disable the clock security system detection interrupt */
      CLK->CSSR &= (uint8_t)(~CLK_CSSR_CSSDIE);
      break;
    default:
      break;
    }
  }
}

/**
  * @brief  Configures the HSI and CPU clock dividers.
  * @param   ClockPrescaler Specifies the HSI or CPU clock divider to apply.
  * @retval None
  */
